<template>
  <div class="tooltip">
    <div class="tooltip-title">{{ formatterList[0].name }}</div>
    <div class="tooltip-item" v-for="(item, index) in formatterList" :key="index">
      <span v-html="item.marker" class="tooltip-item-marker"></span>
      <span
        v-show="formatterList.length > 1"
        class="tooltip-item-seriesName"
        :style="{
          color: item.color
        }"
        >{{ item.seriesName }}</span
      >
      <span class="tooltip-item-data">{{ item.data + fh }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
interface FORMATTERLIST {
  name: string
  seriesName: string
  color: string
  marker: string
  data: number
}

interface Props {
  fh?: string
  formatterList: FORMATTERLIST[]
}

withDefaults(defineProps<Props>(), {
  fh: '',
  formatterList: () => []
})
</script>

<style lang="scss">
.tooltip {
  &-title {
    font-size: $font-size;
    font-weight: bold;
    color: $color;
    margin-bottom: $margin;
  }
  &-item {
    &-marker,
    &-seriesName,
    &-data {
      font-size: $font-size-mini;
    }

    &-data {
      margin-left: calc($margin-large * 2);
    }
  }
}
</style>
